#ifndef __USER_CAN_H__
#define __USER_CAN_H__


#include "main.h"

#ifdef STM32H7xx_HAL_H

	#ifndef UserCAN_HandleTypeDef
		#define UserCAN_HandleTypeDef FDCAN_HandleTypeDef
	#endif

	#include "fdcan.h"
	
	#include "stm32h7xx_hal_conf.h"

	void USER_FDCAN1_INIT(UserCAN_HandleTypeDef *hfdcan);
	void USER_FDCAN2_INIT(UserCAN_HandleTypeDef *hfdcan);
	void USER_FDCAN3_INIT(UserCAN_HandleTypeDef *hfdcan);
	
	typedef struct FDCAN_Rx_struct
	{
		uint8_t Data[8];
		FDCAN_RxHeaderTypeDef FDCAN_RxHeader;
	}user_FDCAN_Rx_Struct;
	
	void user_get_FDCAN_FIFO0_Msgs(UserCAN_HandleTypeDef *hfdcan,user_FDCAN_Rx_Struct *FDCAN_Rx_struct);
	void user_get_FDCAN_FIFO1_Msgs(UserCAN_HandleTypeDef *hfdcan,user_FDCAN_Rx_Struct *FDCAN_Rx_struct);

#elif defined(__STM32F4xx_HAL_H) || defined(__STM32F1xx_HAL_H)

	#ifndef UserCAN_HandleTypeDef
		#define UserCAN_HandleTypeDef CAN_HandleTypeDef
	#endif

	#include "can.h"
	
	
	#if defined(__STM32F4xx_HAL_H)
		#include "stm32f4xx_hal_conf.h"
	#elif defined(__STM32F1xx_HAL_H)
		#include "stm32f1xx_hal_conf.h"
	#endif

	void USER_CAN1_INIT(UserCAN_HandleTypeDef *hcan);
	#ifdef CAN2
	void USER_CAN2_INIT(UserCAN_HandleTypeDef *hcan);
	#endif

#endif


#endif

